import React, { useEffect, useState } from 'react';
import type { ColumnsType } from 'antd/es/table';
import { connect } from 'umi';
import { Line } from '@ant-design/plots';
import {
  Badge,
  Card,
  Col,
  Collapse,
  ConfigProvider,
  Descriptions,
  Divider,
  Row,
  Spin,
  Table,
  Typography,
  Layout,
  Tooltip,
} from 'antd';
import CompareRadarChart from './CompareRadarChart';
import SecondDetailscore from '../SecondDetailscore';

interface StudentScoreTwoDetialType {
  studentName: string; //姓名
  overallGrade: number; //总成绩
  classRank: number; //班级排名
  majorRank: number; //专业排名
  personal: {
    idealsBeliefs: number; //理想信念
    practicalService: number; //实践服务
    literatureArt: number; //文化艺术
    academicTechnology: number; //学术科技
    socialwork: number; //社会工作
    physicalFitness: number; //体育素质
  };

  classScore: {
    idealsBeliefs: number; //班级平均理想信念
    practicalservice: number; //班级平均实践服务
    literatureArt: number; //班级平均文化艺术
    academicTechnology: number; //班级平均学术科技
    socialwork: number; //班级平均社会工作
    physicalFitness: number; //班级平均体育素质
  };
}
const CourseTwoGrades = (props: any) => {
  const { Panel } = Collapse;
  const { Title } = Typography;
  const [data, setData] = useState<StudentScoreTwoDetialType>();

  const getAllList = () => {
    if (props.dispatch) {
      props.dispatch({
        //路径：model的namespace+effects函数名
        type: 'Model_StudentAnalysisStudentModel/getStudentClassTwoAnalysisEffect',
        payload: {
          value: JSON.parse(props.user.currrentuser).account,
          callback: (value: any) => {
            console.log(value);
            setData(value);
          },
        },
      });
    }
  };
  useEffect(() => {
    console.log(props.user);
    if (props.user.currrentuser.length != 0) {
      console.log(JSON.parse(props.user.currrentuser));
      getAllList();
    }
  }, [props]);
  return (
    <Layout style={{ backgroundColor: 'white', width: '100%' }}>
      <div>
        <Card style={{ marginBottom: 30 }}>
          <Typography.Title level={4} style={{ marginBottom: 0 }}>
            学生二课成绩基本信息
          </Typography.Title>
          <Divider />
          <Descriptions bordered column={2}>
            <Descriptions.Item label="姓名（Name）" span={1}>
              {data?.studentName}
            </Descriptions.Item>
            <Descriptions.Item label="总成绩（overallGrade）" span={1}>
              {data?.overallGrade}
            </Descriptions.Item>
            <Descriptions.Item label="班级排名（classRank）" span={1}>
              {data?.classRank}
            </Descriptions.Item>
            <Descriptions.Item label="专业排名（majorRank）" span={1}>
              {data?.majorRank}
            </Descriptions.Item>
            <Descriptions.Item label="理想信念（idealsBeliefs）" span={1}>
              {data?.personal?.idealsBeliefs}
            </Descriptions.Item>
            <Descriptions.Item label="实践服务（practicalService）" span={1}>
              {data?.personal?.practicalService}
            </Descriptions.Item>
            <Descriptions.Item label="文化艺术（literatureArt）" span={1}>
              {data?.personal?.literatureArt}
            </Descriptions.Item>
            <Descriptions.Item label="学术科技（academicTechnology）" span={1}>
              {data?.personal?.academicTechnology}
            </Descriptions.Item>
            <Descriptions.Item label="社会工作（socialWork）" span={1}>
              {data?.personal?.socialWork}
            </Descriptions.Item>
            <Descriptions.Item label="体育素质（physicalFitness）" span={1}>
              {data?.personal?.physicalFitness}
            </Descriptions.Item>
          </Descriptions>
        </Card>
        <SecondDetailscore />
        <Card>
          <Typography.Title level={4} style={{ marginBottom: 0 }}>
            第二课堂成绩分析
          </Typography.Title>
          <Divider />
          <Row gutter={8}>
            <Col span={12}>
              <Collapse defaultActiveKey={['1']} span={6}>
                <Panel
                  header={
                    <Tooltip title="展示学生目前二课成绩分布，六个发展方向的发展状况">
                      <div>第二课堂成绩分布图</div>
                    </Tooltip>
                  }
                  key="1"
                  forceRender
                >
                  <CompareRadarChart />
                </Panel>
              </Collapse>
            </Col>
            <Col span={12}>
              <Collapse defaultActiveKey={['1']}>
                <Panel header={'学生评语'} key="1" forceRender>
                  <Title level={4}>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    {
                      '该生在校期间态度端正，严于律己。在学业方面，该生善于创造，思维活跃，具有潜力，有继续提升的空间。同时该学生有良好的道德素养，坚定的政治方向。遵守社会和学校的规章制度，严格要求自己。'
                    }
                  </Title>
                </Panel>
              </Collapse>
            </Col>
          </Row>
        </Card>
      </div>
    </Layout>
  );
};

export default connect(({ Model_StudentAnalysisStudentModel, user }: any) => ({
  Model_StudentAnalysisStudentModel,
  user,
}))(CourseTwoGrades);
